Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.default = void 0;

var t = require("../../@babel/runtime/helpers/defineProperty"), e = require("../../@babel/runtime/helpers/toConsumableArray");

require("../../@babel/runtime/helpers/Objectvalues");

var a = require("../../@babel/runtime/helpers/classCallCheck"), i = require("../../@babel/runtime/helpers/createClass"), s = function() {
    function s(t) {
        a(this, s), this.loading = !1, this.finished = !1, this.dataName = t, this.dataPath = "".concat(t), 
        this.pages = 0, this.length = 0, this.limit = 15, this.loadPage = 1;
    }
    return i(s, [ {
        key: "bind",
        value: function(t) {
            return this.PageThis = t, this;
        }
    }, {
        key: "push",
        value: function(t) {
            var a = this, i = this.PageThis.data, s = Object.keys(i[this.dataName]).length, h = "page_";
            s > 0 ? Object.values(i[this.dataName]).pop().length >= this.limit ? h += s + 1 : h += s : h += "1";
            var r = "".concat(this.dataPath, ".").concat(h), n = {};
            if (i[this.dataPath][h]) {
                var l = i[this.dataPath][h].length;
                if (Array.isArray(t)) for (var c = 0; c < t.length; c++) {
                    var o = c + l;
                    n["".concat(r, "[").concat(o, "]")] = t[c];
                } else n["".concat(r, "[").concat(l, "]")] = t;
            } else n[r] = Array.isArray(t) ? e(t) : t;
            return this.PageThis.setData(n, function() {
                a.length++, a.pages++, a.loadPage++;
            }), this;
        }
    }, {
        key: "removePage",
        value: function(e) {
            this.PageThis.setData(t({}, "".concat(this.dataPath, ".page_").concat(e), [])), 
            this.pages--;
        }
    }, {
        key: "removeItem",
        value: function(e, a) {
            var i = this, s = "".concat(this.dataPath, ".page_").concat(e), h = this.PageThis.data[this.dataPath]["page_" + e];
            h.splice(a, 1), this.PageThis.setData(t({}, s, h), function() {
                i.length--;
            });
        }
    }, {
        key: "clean",
        value: function() {
            this.pages = 0, this.length = 0, this.loading = !1, this.finished = !1, this.loadPage = 1, 
            this.PageThis.setData(t({}, this.dataPath, {}));
        }
    } ]), s;
}();

exports.default = s;